#
#	Makefile for dcmdata/libsrc
#

@SET_MAKE@

SHELL = /bin/sh
VPATH = @srcdir@:@top_srcdir@/include:@top_srcdir@/@configdir@/include
srcdir = @srcdir@
top_srcdir = @top_srcdir@
configdir = @top_srcdir@/@configdir@

include $(configdir)/@common_makefile@

ofstddir = $(top_srcdir)/../ofstd
oflogdir = $(top_srcdir)/../oflog
oficonvdir = $(top_srcdir)/../oficonv

LOCALINCLUDES = -I$(oficonvdir)/include -I$(ofstddir)/include -I$(oflogdir)/include
LIBDIRS = -L$(oficonvdir)/libsrc -L$(ofstddir)/libsrc -L$(oflogdir)/libsrc
LOCALLIBS = -loflog -lofstd -loficonv $(CHARCONVLIBS)
LOCALDEFS =

# Clear environment variable in the scope of this makefile
DCMDICTPATH =

# Special defines for the Library, define them in LOCALDEFS
#   DICOMDIR_WITHOUT_BACKUP
#       no Backup for DICOMDIR files. default: not defined
#   PRINT_REPLACED_DICTIONARY_ENTRIES
#       dump duplicate entries in the data dictionary to stderr

dicomdic = $(top_srcdir)/data/dicom.dic
privatedic = $(top_srcdir)/data/private.dic

# Dictionary objects for building the helper tools mkdeftag and mkdictbi
dict_tools_objs = dctagkey.o dcdicent.o dcdict.o dcvr.o dchashdi.o

objs = dcpixseq.o dcpxitem.o dcuid.o dcerror.o dcencdoc.o\
	dcstack.o dclist.o dcswap.o dctag.o dcxfer.o \
	dcobject.o dcelem.o dcitem.o dcmetinf.o dcdatset.o dcdatutl.o dcspchrs.o \
	dcsequen.o dcfilefo.o dcbytstr.o dcpixel.o dcvrae.o dcvras.o dcvrcs.o \
	dccodec.o dcvrda.o dcvrds.o dcvrdt.o dcvris.o dcvrtm.o dcvrui.o \
	dcchrstr.o dcvrlo.o dcvrlt.o dcvrpn.o dcvrsh.o dcvrst.o dcvrobow.o \
	dcvrat.o dcvrss.o dcvrus.o dcvrsl.o dcvrsv.o dcvrul.o dcvruv.o dcvrulup.o \
	dcvrfl.o dcvrfd.o dcvrpobw.o dcvrof.o dcvrod.o dcvrol.o dcvrov.o dcdirrec.o \
	dcdicdir.o dcrleccd.o dcrlecce.o dcrlecp.o dcrlerp.o dcrledrg.o dcrleerg.o \
	dcdictbi.o dctagkey.o dcdicent.o dcdict.o dcvr.o dchashdi.o cmdlnarg.o \
	dcvrut.o dcvrur.o dcvruc.o dctypes.o dcpcache.o dcddirif.o dcistrma.o \
	dcistrmb.o dcistrmf.o dcistrms.o dcistrmz.o dcostrma.o dcostrmb.o \
	dcostrmf.o dcostrms.o dcostrmz.o dcwcache.o dcpath.o vrscan.o vrscanl.o \
	dcfilter.o dcmatch.o dcjson.o

support_objs = mkdeftag.o mkdictbi.o
support_progs = mkdeftag mkdictbi

# Extra objects needed by support_progs
support_progs_objs = cmdlnarg.o dctypes.o

library = libdcmdata.$(LIBEXT)


all: $(library)

$(library): $(objs)
	$(AR) $(ARFLAGS) $@ $(objs)
	$(RANLIB) $@

mkdeftag: mkdeftag.o $(dict_tools_objs) $(support_progs_objs)
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(dict_tools_objs) $(support_progs_objs) $(LOCALLIBS) $(LIBS)

mkdictbi: mkdictbi.o $(dict_tools_objs) $(support_progs_objs)
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(dict_tools_objs) $(support_progs_objs) $(LOCALLIBS) $(LIBS)

mkvrscan:
	flex -8 --header-file=vrscanl.h --outfile=vrscanl.c vrscanl.l


# Generate a new include file of defined tags
updatedeftag: mkdeftag $(dicomdic) $(privatedic)
	`pwd`/mkdeftag -o $(top_srcdir)/include/dcmtk/dcmdata/dcdeftag.h $(dicomdic) $(privatedic)

# Generate a builtin data dictionary from $(dicomdic) and $(privatedic)
updatebuiltindict: mkdictbi $(dicomdic) $(privatedic)
	`pwd`/mkdictbi $(dicomdic) $(privatedic) > dcdictbi.cc


install: $(library)
	$(configdir)/mkinstalldirs $(DESTDIR)$(libdir)
	$(INSTALL_DATA) $(library) $(DESTDIR)$(libdir)/$(library)
	$(RANLIB) $(DESTDIR)$(libdir)/$(library)


clean:
	rm -f $(support_progs) $(support_objs) $(objs) $(library) $(TRASH)

distclean: clean
	rm -f $(DISTTRASH)


dependencies:
	$(CXX) -MM $(defines) $(includes) $(CPPFLAGS) $(CXXFLAGS) *.cc  > $(DEP)

include $(DEP)
